#include <iostream>
#include <unordered_map>
#include <vector>
#include <map>

using namespace std;

// 1394. 找出数组中的幸运数
// https://leetcode.cn/problems/find-lucky-integer-in-an-array/description/?envType=daily-question&envId=2025-07-05

class Solution {
public:
    int findLucky(vector<int>& arr) {
        map<int, int> freq;
        for (int i = 0; i < arr.size(); i++){
            freq[arr[i]]++;
        }
        int ans = -1;
        for(auto &[key,value]: freq){
            if(key == value){
                ans = key;
            }
        }
        return ans;
    }
};

int main()
{
    return 0;
}